package com.tjw.ec.upms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tjw.ec.common.core.util.PageUtils;
import com.tjw.ec.common.core.util.Query;
import com.tjw.ec.upms.api.dto.RoleVO;
import com.tjw.ec.upms.api.entity.RoleEntity;
import com.tjw.ec.upms.dao.RoleDao;
import com.tjw.ec.upms.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 角色表,基本权限的集合。无上级与下级之分;
 *
 * @author T-junwen
 * @email t-junwen@foxmail.com
 * @date 2019-07-27 16:43:31
 */
@Service("roleService")
public class RoleServiceImpl extends ServiceImpl<RoleDao, RoleEntity> implements RoleService {

    @Autowired
    private RoleDao roleDao;

    @Override
    public PageUtils<RoleEntity> queryPage(Map<String, Object> params) {

        IPage<RoleEntity> page = new Query<RoleEntity>(params).getPage();

        QueryWrapper<RoleEntity> queryWrapper = new QueryWrapper<>();

        IPage<RoleEntity> data = baseMapper.selectPage(
                page,
                queryWrapper
        );

        return new PageUtils(data);
    }

    /**
     * @param userId
     * @Title: 查询用户角色列表
     * @Param: []
     * @return: java.util.List<com.tjw.ec.upms.api.dto.RoleVO>
     * @Author: 田俊文
     * @Date: 2019/8/2 14:11
     * @Throws:
     */
    @Override
    public List<RoleVO> getRoleByUserId(String userId) {
        List<RoleVO> roles = roleDao.getRoleByUserId(userId);
        return roles;
    }

}
